Replication Files for "Heterogeneity and Aggregate Fluctuations"
by Minsu Chang, Xiaohong Chen, and Frank Schorfheide
For questions, please email Minsu Chang at minsu.chang@georgetown.edu

The scripts in this directory produce the results for Section 5:

/Data/ contains the simulated data from the code in /KS_Solution_v2/
/Figures/ contains the folders where figures generated by the code will be saved 
/Functions/ contains Julia functions that are used by the scripts
/Results/ contains the folders where main outputs of the Julia scripts will be saved /SpecFiles/ contains files with information on the fVAR specification and MCMC configurations.

JULIA scripts:

1. script_Density_estimation.jl: this script estimates the log-spline densities for each period t and stores the alpha estimates.

2. script_MDD.jl: this script loops over K, lambda, and number of lags to compute the MDD approximation. The output is used to generate Table 3.

Density estimation and MDD estimation need to be run separately for fVARspec1 (N=1,000), fVARspec2 (N=5,000), and fVARspec3 (N=10,000), 

3. script_VAR_estimation.jl: given a particular K and lambda, this script estimates the functional VAR, using the a-hats in place of the true a's.

4. script_SS_estimation.jl: given a particular K and lambda, this script estimates the functional state-space model with a measurement equation that connect the a-hats to the a's.

5. script_IRF.jl: converts posterior draws of (Phi,Sigma) into impulse responses.

6. script_Alpha_Smoothed.jl: generates smoothed estimates of the alpha(t)s. Output is not used in paper.

7. script_AggVAR_MDD.jl: loops over K, lambda, and number of lags to compute the MDD for VAR with aggregate variables only.

8. script_AggVAR_Estimimation.jl: estimate aggregate VAR. AggVARspec3 (2 lags), AggVARspec4 (1 lag)

9. script_AggVAR_IRF.jl: creates IRFs to TFP shock identified by Cholesky factorization

10. Graph_Densities.m: plots estimated and true cross-sectional densities (Fig 4)

11. Graph_IRF_fVAR_AggVAR.m: overlays two sets of IRFs of aggregate variables 
to aggregate shock (Fig 5)

12. Graph_IRF_DensDiff.m: generates IRFs of density differential (Fig 6)

13. script_AltVAR_MDD.jl: compute MDD for hyperparameter selection.

14. script_AltVAR_Estimation.jl: estimate alternative VAR conditional on
hyperparameters. AltVARspec4P = Pctl

15. script_AltVAR_IRF.jl: convert parameters into IRFs.

16. Graph_IRF_fVAR_AltVAR_Pctl.m: overlays two sets of IRFs of percentiles to aggregate shock (Fig 7)

